<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/iconfont.css">
<link rel="stylesheet" href="css/global.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/swiper.min.css">
<link rel="stylesheet" href="css/styles.css">
<script src="js/jquery.1.12.4.min.js" charset="UTF-8"></script>
<script src="js/bootstrap.min.js" charset="UTF-8"></script>
<script src="js/swiper.min.js" charset="UTF-8"></script>
<script src="js/global.js" charset="UTF-8"></script>
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<!-- <script src="js/jquery.DJMask.2.1.1.js" charset="UTF-8"></script> -->
<title>广内殿</title>
<script type="text/javascript">
		
		
	</script>
</head>
<body>
	<!-- 顶部tab -->
	<div class="tab-header">
		<div class="inner">
			<div class="pull-left">
				<div class="pull-left">
					嗨，欢迎来到<span class="cr">广内殿</span>
				</div>
			</div>
			<div class="pull-right">
				<span id="yinCang"> <a href="login.html"><span class="cr">登录</span></a>
					<a href="login2.html">注册</a>
				</span> 
				<span style="display: none;" id="xianShi"> 
					uid:<span id="uId"></span> 
					欢迎:<span id="uName"></span>
				</span> 
				<a href="udai_setting.html">个人中心</a> <a href="udai_order.html">我的订单</a>
			</div>
		</div>
	</div>
	<!-- 顶部标题 -->
	<div class="bgf5 clearfix">
		<div class="top-user">
			<div class="inner">
				<a class="logo" href="index.html"><img
					src="images/icons/logo.jpg" alt="U袋网" class="cover"></a>
				<div class="title">个人中心</div>
			</div>
		</div>
	</div>
	<div class="content clearfix bgf5">
		<section class="user-center inner clearfix">
			<div class="pull-left bgf">
				<a href="udai_setting.html" class="title">广内殿欢迎页</a>
				<dl class="user-center__nav">
					<dt>帐户信息</dt>
					<a href="udai_setting.html"><dd>个人资料</dd></a>
					<a href="udai_address_edit.html"><dd class="active">收货地址</dd></a>
					<a href="udai_pwd_modify.html"><dd>修改登录密码</dd></a>
				</dl>
				<dl class="user-center__nav">
					<dt>订单中心</dt>
					<a href="udai_order.html"><dd>我的订单</dd></a>
				</dl>
			</div>
			<div class="pull-right">
				<div class="user-content__box clearfix bgf">
					<div class="title">账户信息-编辑收货地址</div>
					<form action="" class="user-addr__form form-horizontal" role="form">
						<p class="fz18 cr">
							编辑收货地址<span class="c6" style="margin-left: 20px">电话号码、手机号码选填一项，其余均为必填项</span>
						</p>
						<div class="form-group">
							<label for="name" class="col-sm-2 control-label">收货人姓名：</label>
							<div class="col-sm-6">
								<input class="form-control" id="name" placeholder="请输入姓名"
									type="text">
							</div>
						</div>
						<div class="form-group">
							<label for="details" class="col-sm-2 control-label">收货地址：</label>
							<div class="col-sm-10">
								<div class="addr-linkage">
									<select id="province" name="province"></select> 
									<select id="city" name="city"></select> 
									<select id="area" name="area"></select>
									<select name="town"></select>
								</div>
								<!-- <input class="form-control" id="details" placeholder="建议您如实填写详细收货地址，例如街道名称，门牌号码等信息" maxlength="30" value="世界金龙大厦20层B北 福州腾讯企点运营中心" type="text"> -->
							</div>
						</div>
						<!-- <div class="form-group">
							<label for="code" class="col-sm-2 control-label">地区编码：</label>
							<div class="col-sm-6">
								<input class="form-control" id="code" placeholder="请输入邮政编码" type="text">
							</div>
						</div> -->
						<div class="form-group">
							<label for="mobile" class="col-sm-2 control-label">手机号码：</label>
							<div class="col-sm-6">
								<input class="form-control" id="mobile" placeholder="请输入手机号码"
									type="text">
							</div>
						</div>

						
						<div class="form-group">
							<div class="col-sm-offset-2 col-sm-6">
								<button type="button" onclick="xg()" class="but">修改</button>
							</div>
						</div>
						<script src="js/jquery.citys.js"></script>
						<script src="layer/layer.js"></script>
						<script>
						function xg(){
							
							var aid=JSON.parse(window.localStorage.getItem("a1"));
							$.post("xgAdd",{
								a_name:$("#name").val(),
								a_phone:$("#mobile").val(),
								province:$("#province option:checked").text(),
								city:$("#city option:checked").text(),
								address:$("#area option:checked").text(),
								a_id:aid
							},function(res){
								if (res.code=="0") {
									layer.msg(res.msg);
									window.location.href="udai_address_edit.html";
								} else {
									layer.msg(res.msg);
								}
							},"json");
						}
							$(document).ready(function(){
								var u=JSON.parse(window.localStorage.getItem("user"));
								console.log(u);
								if (u!=null) {
									$("#yinCang").hide();
									$("#xianShi").show();
									$("#uName").html(u.username);
									$("#uId").html(u.uid);
								}
								// 添加街道/乡镇
								function townFormat(info){
									$('.addr-linkage select[name="town"]').hide().empty();
									if (info['code'] % 1e4 && info['code'] < 7e6){	//是否为“区”且不是港澳台地区
										var ajaxConfig = {
											url: 'http://passer-by.com/data_location/town/' + info['code'] + '.json',
											scriptCharset:'UTF-8',
											dataType: "json",
											timeout: 4000,
											success: function(data) {
												$('.addr-linkage select[name="town"]').show();
												// $('#code').val(info['code']) // 填地区编码
												for (i in data) {
													$('.addr-linkage select[name="town"]').append(
														'<option value="' + data[i] + '">' + data[i] + '</option>'
													);
												};
												$('.addr-linkage select[name="town"]').find('option[value="洪山镇"]').prop("selected", "selected");
											},
										};
										$.ajax(ajaxConfig).fail(function(p1,p2,p3){
											ajaxConfig.url = 'js/data_location/town/' + info['code'] + '.json';
											$.ajax(ajaxConfig)
										});
									}
								};
								var aid=JSON.parse(window.localStorage.getItem("a1"));
								console.log(aid);
								$.post("selectAdd",{a_id:aid},function(res){
									if (res.code=="0") {
										var p=res.data.province;
										var c=res.data.city;
										var a=res.data.address;
										$('.addr-linkage').citys({
											// 如果某天这个仓库地址失效了dataUrl请使用本地 2017.10 的数据 'js/data_location/list.json'
											dataUrl: 'http://passer-by.com/data_location/list.json',
											spareUrl: 'js/data_location/list.json',
											dataType: 'json',
											valueType: 'name',
											province: p,
											city:c,
											area: a,
											onChange: function(data) {
												townFormat(data)
											},
										},function(api){
											var info = api.getInfo();
											townFormat(info);
										});
										
										$("#name").val(res.data.a_name);
										$("#mobile").val(res.data.a_phone);
									} else {

								}
								},"json");
								
								
							}); 
						</script>
					</form>
					
				</div>
			</div>
		</section>
	</div>
	<!-- 右侧菜单 -->

	<!-- 底部信息 -->
	<div class="footer">


		<div class="copy-box clearfix">
			<!-- 版权 -->
			<p class="copyright">
				© 2005-2017 U袋网 版权所有，并保留所有权利<br>
				ICP备案证书号：闽ICP备16015525号-2&nbsp;&nbsp;&nbsp;&nbsp;福建省宁德市福鼎市南下村小区（锦昌阁）1栋1梯602室&nbsp;&nbsp;&nbsp;&nbsp;Tel:
				18650406668&nbsp;&nbsp;&nbsp;&nbsp;E-mail: 18650406668@qq.com
			</p>
		</div>
	</div>
</body>
</html>